Analog-to-Digital conversion
via the Texas Instruments MSP430 Microcontroller
Ian McCall November
6, 2013
ECE 480
Design Team 7
Abstract
The MSP430 is a line of
microcontrollers (MCUs) designed and manufactured by Texas Instruments. These MCUs,
which are inexpensive and consume little power, feature several peripherals
that can be utilized to accomplish a wide variety of tasks. One example is an
analog-to-digital converter (ADC) that can measure and capture analog signals
so they can be then processed by the MCU.
The ADCs that are included in the various MSP430 iterations have
multiple channels to handle multiple analog input signals as well as several
modes of operation.
Introduction
The ADC featured on the MSP430 line
of microcontrollers is an eight channel, ten bit analog-to-digital converter.
This means that the MSP430 can perform analog-to-digital conversions on up to
eight input signals with ten bit resolution. This enables the MCU to measure
analog input signals, respond to these inputs, and subsequently perform
different tasks using these inputs, which serves as a rather powerful tool in
many applications. For example, in a dual-parachute rocket system, the MSP430
can trigger the ejection parachutes given voltage readings from the on-board
electronics (accelerometer, altimeter, etc).
Figure 1
- MSP430 Launchpad
Objective
The objective of this application
note is to educate users regarding the ADC peripherals of the MSP430 line of
microcontrollers. Topics that will be covered include the different operating
modes and MCU registers associated with the ADC peripheral, and software
configuration of the ADC with examples of code relating to the various aspects
of the ADC.
Hardware
and Software
Along with the MSP430 microcontroller, Texas Instruments also
provides a development board that is an essential part of creating MSP430 applications,
called the LaunchPad. It features on-board emulation for debugging the MSP430.
To develop code, TI produced an integrated development environment called Code
Composer Studio (CCS). The LaunchPad can connect to a personal computer via a
mini-USB cable included with the LaunchPad, which powers the board and allows
the user to program and debug (using CCS) the MSP430. Once it has been
programmed, the MCU can be removed from the LaunchPad and installed in whatever
system it was programmed for.
ADC Modes
The ADC present on the MSP430 has
four modes of operation: single channel single-conversion,
sequence-of-channels, repeat single-channel, and repeat sequence-of-channels.
Below is a table giving a brief description of each mode.

Figure 2
- ADC Conversion Modes
ADC Conversion Process
The general order of actions that the
ADC performs for each conversion is exhibited in the single channel
single-conversion mode:
1. The conversion mode is selected
2. The ADC is turned on
3. The input channel is selected
4. The ADC waits to be enabled or
instructed to start conversion
5. When a conversion is triggered, the
voltage at the selected input is sampled
6. The voltage is then converted to a
digital value
7. This value is written to the ADC
memory register
8. An ADC interrupt is triggered
9. The ADC waits again to be instructed
to start a conversion
The process
described above is illustrated on the next page. In the other conversion modes,
this process differs only in that multiple channels are being sampled, or
individual channels are sampled repeatedly.

Figure 3 - Conversion Process for Single Channel Single-Conversion mode
ADC Registers
The MSP430 has several control
registers that are used to configure various operating parameters of the
peripheral that they correspond to. The registers that are used by the ADC are
listed in the table on the next page.

Figure 4 - ADC Registers
The registers that are used to
configure the operation of the ADC are the control registers ADC10CTL0 and
ADC10CTL1. The figures below show the contents of these registers:

Figure 5 - ADC10CTL0 Register

Figure 6 - ADC10CTL1 Register
On the next page is a table giving a
brief description of the portions of these control registers that are essential
for basic use of the ADC.

Figure 7 - Description of key control register sections
Configuring the ADC
The ADC can be configured with only a
few lines of code. An example of simple configuration, written in the C++
programming language, is implemented in the block of code below.

Figure 8 - ADC Configuration Code Example
The symbols such as ADC10ON and INCH_5
that can be seen in the above example stand for binary values that configure
the ADC control registers. The different configuration options and
corresponding symbols are defined in the MSP430 User’s Guide, which is linked to
in the references section. In this particular example, the ADC is turned on and
channel five is selected as the input channel. The SMCLK is selected as the ADC
clock and the ADC interrupt is enabled. The ADC is instructed to hold its
samples for 64 clock ticks before making a conversion. By default, the ADC is
in single channel single-conversion mode. When instructed, the ADC begins
conversion and the CPU will wait until the ADC10BUSY bit is cleared before
continuing program execution. The ADC triggers an interrupt every time it
performs a conversion, therefore it is necessary to write an interrupt service
routine (ISR) to handle the interrupt for the ADC to function properly. An
example of an ISR is shown below:

Figure 9 - ADC ISR example
This code can be executed at time
intervals defined by a timer peripheral on the MSP430 to achieve the desired
sample rate.
Conclusion
The analog-to-digital converter
included on the MSP430 microcontroller can be a powerful tool for developers of
applications using this device. It allows users to measure analog signals such
as sensor outputs for instrumentation or control applications. This application
note introduced users to the different operating modes and registers associated
with the ADC and showed how it can be configured with software for the desired
application.
References
1. MSP430 User’s Guide – http://www.ti.com/product/msp4302553
2. MSP430 LaunchPad Wiki – http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_(MSP-EXP430G2)